﻿
using System;

namespace Library.WebControls {
	internal static class StringUtil {
		internal static int? ParseInt(this string text) {
			if (String.IsNullOrEmpty(text)) return null;
			int value;
			if (Int32.TryParse(text, out value)) return value;
			return null;
		}
		internal static int? ParseInt(this object text) {
			if (text == null) return null;
			return ParseInt(text.ToString());
		}

		internal static string NullToEmpty(this string text) {
			if (text == null) return String.Empty;
			return text;
		}

		internal static string NullToEmpty(this object text) {
			if (text == null) return String.Empty;
			return text.ToString();
		}
	}

}
